<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="vo.*,Dao.*,common.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
request.setCharacterEncoding("utf-8");
String realname = request.getParameter("realname");
String username = request.getParameter("username");
String gender = request.getParameter("options");
String email = request.getParameter("email");
String phone = request.getParameter("phone");
String password = request.getParameter("pass");
Md5 md = new Md5();
String password2 = md.getMD5(password);
User user = new User();
user.setRealname(realname);
user.setUsername(username);
user.setGender(gender);
user.setEmail(email);
user.setPhone(phone);
user.setPassword(password2);
Userdao dao = new Userdao();
boolean re = dao.isExitUname(user);
if(re){
	%>
	<script type="text/javascript">
	window.alert("邮箱已被注册！");
	window.location.href="ZhuCe.jsp";
	</script>
	<% 
}else{
int result = dao.do_register(user);
if(result>0){
	%>
	<script type="text/javascript">
	window.alert("注册成功！");
	window.location.href="Login.jsp";
	</script>
	<% 
}else{
	%>
	<script type="text/javascript">
	window.alert("注册失败！");
	window.location.href="ZhuCe.jsp";
	</script>
	<%
}
}
%>
</body>
</html>